from pydantic import BaseModel, field_validator
from datetime import datetime
from myProfile.models.data.myProfile_models import Gender, Education, \
    Position, Permission
from typing import Dict, Optional


class SignupReq(BaseModel):
    id: Optional[int] = None
    username: Optional[str] = None
    password: Optional[str] = None


class LoginReq(BaseModel):
    permission_sets: list[Permission]


class ProfileReq(BaseModel):
    fullname: Optional[str] = None
    gender: Optional[Gender] = None
    age: Optional[int] = None
    education: Optional[Education] = None
    position: Optional[Position] = None


class PsychoTestReq(BaseModel):
    id: int
    test_date: datetime
    test_name: str
    answers: Dict
    scores: Dict

    @field_validator('test_date')
    def pmh_date_datetime(cls, value):
        return datetime.strptime(value.strftime('%Y-%m-%dT%H:%M:%S'),
                                 "%Y-%m-%dT%H:%M:%S")


class PMHReq(BaseModel):
    id: int
    pmh_date: datetime
    symptoms: str
    diagnosis: str

    @field_validator('pmh_date')
    def pmh_date_datetime(cls, value):
        return datetime.strptime(value.strftime('%Y-%m-%dT%H:%M:%S'),
                                 "%Y-%m-%dT%H:%M:%S")


class FMHReq(BaseModel):
    id: int
    relations: str
    symptoms: str
    diagnosis: str


class PsychoTherapyReq(BaseModel):
    id: int
    psycho_therapy_date: datetime
    psycho_therapy: str
    duration: str

    @field_validator('psycho_therapy_date')
    def psycho_therapy_date_datetime(cls, value):
        return datetime.strptime(value.strftime('%Y-%m-%dT%H:%M:%S'),
                                 "%Y-%m-%dT%H:%M:%S")


class MedicationReq(BaseModel):
    id: int
    medication_date: datetime
    medications: str
    duration: str

    @field_validator('medication_date')
    def medication_date_datetime(cls, value):
        return datetime.strptime(value.strftime('%Y-%m-%dT%H:%M:%S'),
                                 "%Y-%m-%dT%H:%M:%S")


class LifeEventReq(BaseModel):
    id: int
    life_event_date: datetime
    life_events: str
    duration: str

    @field_validator('life_event_date')
    def life_event_date_datetime(cls, value):
        return datetime.strptime(value.strftime('%Y-%m-%dT%H:%M:%S'),
                                 "%Y-%m-%dT%H:%M:%S")


class IntervetionReq(BaseModel):
    id: int
    intervention_date: datetime
    interventions: str
    duration: str

    @field_validator('intervention_date')
    def intervention_date_datetime(cls, value):
        return datetime.strptime(value.strftime('%Y-%m-%dT%H:%M:%S'),
                                 "%Y-%m-%dT%H:%M:%S")


if __name__ == "__main__":

    pass
